IF  EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_ssis_addlogentry]') AND type in (N'P', N'PC'))
BEGIN
     DROP PROCEDURE [dbo].[sp_ssis_addlogentry]
END
GO

CREATE PROCEDURE [dbo].[sp_ssis_addlogentry]
     @event       sysname,
     @computer    nvarchar(128),
     @operator    nvarchar(128),
     @source      nvarchar(1024),
     @sourceid    uniqueidentifier,
     @executionid uniqueidentifier,
     @starttime   datetime,
     @endtime     datetime,
     @datacode    int,
     @databytes   image,
     @message     nvarchar(2048)
AS
/*
 *
 * sp_ssis_addlogentry
 *
 * Purpose:      
 *
 * Inputs:       
 *
 * Assumes:      
 *
 * Effects:      
 *
 * Returns:      
 *
 * Calling
 * Application:  
 *
 * Note(s):      
 *
 * Author(s):    NOVA Concepts Ltd.
 *
 * Change Log:   Initial Release, 11/18/2011, 1.00.0000
 *
 */
BEGIN
     INSERT dbo.EventLog
          ( EventLogTypeId,
            LogByApp,
            LogByAppSubSystem,
            MiscVC1,
            MiscVC2,
            MiscVC3,
            TraceText,
            MiscGUID1,
            MiscGUID4,
            MiscDt1,
            MiscDt2,
            MiscInt1,
            MiscTinyint1,
            TraceImage,
            LogText )
     SELECT 1, -- Informational
            'Integration Services',
            'sp_ssis_addlogentry',
            @event,
            @computer,
            @operator,
            @source,
            @sourceid,
            @executionid,
            @starttime,
            @endtime,
            @datacode,
            10, -- SSIS version, SQL 2008
            @databytes,
            @message
END
GO

EXEC sp_addextendedproperty @name = N'MS_Description', @value = 'Inserts a SSIS (SQL 2008) log entry into the EventLog table.  This sproc name is the standard name that the SSIS SQL Server logging is expecting, instead of writing the data to a MS specifically named table it is written into the EventLog table.', @level0type = N'Schema', @level0name = dbo, @level1type = N'PROCEDURE', @level1name = sp_ssis_addlogentry;
GO
